<?php
/**
 * Author Yulin
 * Email  dwzhanglong@126.com
 * Date   2017-9-19
 * Func   台湾宾果
 */
defined('IN_YuLin') || exit('NO PERMIT!');

//	返回中奖金额	data为订单信息，plays为玩法

function PrizeCount_12($data,$plays)
{
	if(!$data || !$data['result'] || !$plays)
	{
		return 0;
	}
	
	//	玩法
	$result = explode(',',$data['result']);
	
	//	任选一
	if($plays['playid'] == 21103)
	{
		$tmp3 = 0;
		$tmp = explode('|',$data['rednum']);
		foreach($tmp as $t)
		{
			in_array($t,$result) && $tmp3++;
		}
		
		return $tmp3 * $plays['maxprize'] * $data['times'];
	}
	
	//	任选二
	if($plays['playid'] == 21104)
	{
		$tmp3 = 0;
		$tmp = explode('|',$data['rednum']);
		foreach($tmp as $t)
		{
			in_array($t,$result) && $tmp3++;
		}
		
		return $tmp3 > 1 ? NumGroup($tmp3,2) * $plays['maxprize'] * $data['times'] : 0;
	}
	
	//	任选三
	if($plays['playid'] == 21105)
	{
		$tmp3 = 0;
		$tmp = explode('|',$data['rednum']);
		foreach($tmp as $t)
		{
			in_array($t,$result) && $tmp3++;
		}
		
		return $tmp3 > 2 ? NumGroup($tmp3,3) * $plays['maxprize'] * $data['times'] : 0;
	}
	
	//	任选四
	if($plays['playid'] == 21106)
	{
		$tmp3 = 0;
		$tmp = explode('|',$data['rednum']);
		foreach($tmp as $t)
		{
			in_array($t,$result) && $tmp3++;
		}
		
		return $tmp3 > 3 ? NumGroup($tmp3,4) * $plays['maxprize'] * $data['times'] : 0;
	}
	
	//	任选五
	if($plays['playid'] == 21107)
	{
		$tmp3 = 0;
		$tmp = explode('|',$data['rednum']);
		foreach($tmp as $t)
		{
			in_array($t,$result) && $tmp3++;
		}
		
		return $tmp3 > 4 ? NumGroup($tmp3,5) * $plays['maxprize'] * $data['times'] : 0;
	}
	
	//	任选六
	if($plays['playid'] == 21108)
	{
		$tmp3 = 0;
		$tmp = explode('|',$data['rednum']);
		foreach($tmp as $t)
		{
			in_array($t,$result) && $tmp3++;
		}
		
		return $tmp3 > 5 ? NumGroup($tmp3,6) * $plays['maxprize'] * $data['times'] : 0;
	}
	
	//	任选七
	if($plays['playid'] == 21109)
	{
		$tmp3 = 0;
		$tmp = explode('|',$data['rednum']);
		foreach($tmp as $t)
		{
			in_array($t,$result) && $tmp3++;
		}
		
		return $tmp3 > 6 ? NumGroup($tmp3,7) * $plays['maxprize'] * $data['times'] : 0;
	}
	
	//	和值单双、大小和
	$hezhi = array_sum($result);
	if(in_array($plays['playid'],[21110,21115]))
	{
		return $hezhi % 2 ? $plays['maxprize'] * $data['times'] : 0;
	}
	if(in_array($plays['playid'],[21265,21275]))
	{
		return $hezhi % 2 == 0 ? $plays['maxprize'] * $data['times'] : 0;
	}
	if(in_array($plays['playid'],[21111,21116]))
	{
		return $hezhi == 810 ? $plays['maxprize'] * $data['times'] : 0;
	}
	if(in_array($plays['playid'],[21266,21276]))
	{
		return $hezhi > 810 ? $plays['maxprize'] * $data['times'] : 0;
	}
	if(in_array($plays['playid'],[21267,21277]))
	{
		return $hezhi < 810 ? $plays['maxprize'] * $data['times'] : 0;
	}
	
	//	上中下盘，奇偶和盘
	$shang = $ji = 0;
	foreach($result as $t)
	{
		$t < 41 && $shang++;
		$t % 2 && $ji++;
	}
	if(in_array($plays['playid'],[21112,21118]))
	{
		return $shang == 10 ? $plays['maxprize'] * $data['times'] : 0;
	}
	if(in_array($plays['playid'],[21268,21281]))
	{
		return $shang > 10 ? $plays['maxprize'] * $data['times'] : 0;
	}
	if(in_array($plays['playid'],[21269,21282]))
	{
		return $shang < 10 ? $plays['maxprize'] * $data['times'] : 0;
	}
	if(in_array($plays['playid'],[21113,21119]))
	{
		return $ji == 10 ? $plays['maxprize'] * $data['times'] : 0;
	}
	if(in_array($plays['playid'],[21270,21283]))
	{
		return $ji > 10 ? $plays['maxprize'] * $data['times'] : 0;
	}
	if(in_array($plays['playid'],[21271,21284]))
	{
		return $ji < 10 ? $plays['maxprize'] * $data['times'] : 0;
	}
	
	//	和值大小单双
	$heda = $hezhi > 810;
	$hedan = $hezhi % 2;
	if(in_array($plays['playid'],[21114,21117]))	//	大单
	{
		return $heda && $hedan ? $plays['maxprize'] * $data['times'] : 0;
	}
	if(in_array($plays['playid'],[21272,21278]))	//	大双
	{
		return $heda && !$hedan ? $plays['maxprize'] * $data['times'] : 0;
	}
	if(in_array($plays['playid'],[21273,21279]))	//	小单
	{
		return !$heda && $hedan ? $plays['maxprize'] * $data['times'] : 0;
	}
	if(in_array($plays['playid'],[21274,21280]))	//	小双
	{
		return !$heda && !$hedan ? $plays['maxprize'] * $data['times'] : 0;
	}
	
	return 0;
}